package datasv.collegeQuery_datasv;

import java.util.ArrayList;
import java.util.List;

import po.CollegeMemberPO;
import logicsv.collegeQuery_logicsv.MemberType;
import data.datafactory.DatabaseOperator;

public class GetCollege {
	public static void main(String[] args) {
		System.out.println(new GetCollege().getCollegeMemberList("001", MemberType.STUDENT).getMemberIDList().get(0));
		System.out.println(new GetCollege().getCollegeMemberList("001", MemberType.TEACHER).getMemberIDList().get(0));
		System.out.println("getCollege Successful");
	}
	public CollegeMemberPO getCollegeMemberList(String collegeID,MemberType type){
		return getCollegeMemList(collegeID,type);
	}
	private CollegeMemberPO getCollegeMemList(String id,MemberType type){
		DatabaseOperator dataop=new DatabaseOperator("college"+id);
		ArrayList<String> list=null;
		if(!dataop.ifDatabaseExist()){
			return null;
		}
		if(type.equals(MemberType.STUDENT)){
			list=dataop.getColumn("student_list", "id");
		}else if(type.equals(MemberType.TEACHER)){
			list=dataop.getColumn("teacher_list", "id");
		}else{
			System.out.println("MemberType Wrong");
		}
		List<String> idList=list;
		CollegeMemberPO collegeMemberPO = new CollegeMemberPO(id, type, idList);
		return collegeMemberPO;
	}
}
